package com.abc.springboot.controller;

import com.abc.springboot.pojo.Teacher;
import com.abc.springboot.service.TeacherService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

@Controller
@ResponseBody
@RequestMapping("/teacher")
public class TeacherController {
    @Autowired
    private TeacherService teacherService;

    @RequestMapping("/queryTeachers")
    public List<Teacher> queryTeachers(){
        return teacherService.queryTeachers();
    }

    @RequestMapping("/query/{id}")
    public Teacher queryTeacherById(@PathVariable int id) {
        return teacherService.queryTeacherById(id);
    }

    @RequestMapping("/updateTeacherById")
    public int updateTeacherById(@RequestBody Teacher teacher){
        return teacherService.updateTeacherById(teacher);
    }

    @RequestMapping("/delete/{id}")
    public int updateTeacherById(@PathVariable int id){
        return teacherService.deleteTeacherById(id);
    }

}
